<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('库存列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li style="width: 250px">
                                <input id="treeId" name="deptId" type="hidden"  />
                                <label>门店：</label>
                                <div class="input-group">
                                    <input class="form-control" type="text" onclick="selectDeptTree()" id="treeName"  readonly="true">
                                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                                </div>
                            </li>
                            <li>
                                <label>货名：</label>
                                <input type="text" name="goodsId"/>
                            </li>
                            <li>
                                <label>条码：</label>
                                <input type="text" name="barCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="goods:repertory:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="goods:repertory:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goods:repertory:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="goods:repertory:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('goods:repertory:edit')}]];
        var removeFlag = [[${@permission.hasPermi('goods:repertory:remove')}]];
        var prefix = ctx + "goods/repertory";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "库存",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'deptName',
                    title: '门店'
                },
                {
                    field: 'barCode',
                    title: '条码'
                },
                {
                    field: 'goodsName',
                    title: '货品'
                },
                {
                    field: 'quantity',
                    title: '货品数量'
                },
                {
                    field: 'lastUpdateTime',
                    title: '最后更新时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        //actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        /*门店管理-新增-选择父门店树*/
        function selectDeptTree() {
            var treeId=$("#treeId").val();
            if(treeId==''){treeId='100'}
            var xprefix = ctx + "system/dept";
            var options = {
                title: '门店选择',
                width: "380",
                url: xprefix + "/selectDeptTree/" +treeId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var tid=body.find('#treeId').val();
            var tval=body.find('#treeName').val();
            console.log(tid+""+tval)
            $("#treeId").val(tid);
            $("#treeName").val(tval);
            layer.close(index);
        }

    </script>
</body>
</html>